package com.mbmed.doctor.commons.vo.exception;

import com.mbmed.doctor.commons.utils.ReflectUtil;


/**
 * 基本异常, 继承自RuntimeException.
 * <br>从由Spring管理事务的函数中抛出时会触发事务回滚.
 * 
 * @author 贾海勇
 * @date 2014-05-04
 */
@SuppressWarnings("serial")
public class BaseException extends RuntimeException {

	public BaseException() {
		super();
	}

	public BaseException(String message) {
		super(message);
	}

	public BaseException(Throwable cause) {
		super(cause);
	}

	public BaseException(String message, Throwable cause) {
		super(message, cause);
	}
	
	public static BaseException getDetailMessage(Exception e ){
		if(e instanceof BaseException){
			return (BaseException) e;
		}
		String detailMessage = ReflectUtil.getFieldValue(e.getCause(), "detailMessage");
		return new BaseException(detailMessage);
	}

}
